<template>
    <div >
      
       <el-row :gutter="20" style="margin-top: 20px;">
        <el-button style="float:right" type="warning" @click="chargeregient">收费</el-button>
        <h3>挂号信息</h3>
    
       </el-row>
      
    
        <el-row :gutter="20" style="margin-top: 20px;">
            
        <el-col :span="6">
          
            <div class="grid-content bg-purple" >
              <label>  挂号单号</label>
              <el-input v-model="register.rNo" placeholder="请输入单号"></el-input>
               
            </div>
            
        </el-col>
      <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>接诊科室</label>
               
                <el-input  v-model="register.tDepar" placeholder="请输入科室"></el-input>
            </div>
        </el-col>
      <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>  接诊类型</label>
              
                <el-input   v-model="register.tType" placeholder="请输入接诊类型"></el-input>
            </div>
        </el-col>
      <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>  接诊医生</label>

                
                <el-input  v-model="register.rDoctor" placeholder="请输入医生姓名"></el-input>
    
            </div>
        </el-col>
      
    </el-row>
    
    <el-row :gutter="20"  style="margin-top: 20px;">
        <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>  挂号费</label>
                <el-input   v-model="register.rRegister" placeholder="请输入挂号费"></el-input>
               
               
            </div>
            
        </el-col>
      <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>  诊疗费</label>
                <el-input   v-model="register.rDisease" placeholder="请输入挂号费"></el-input>
               
            </div>
        </el-col>
      <el-col :span="6">
            <div class="grid-content bg-purple">
                <label>  挂号日期</label>
                <div class="block">
                    <span class="demonstration"></span>
                    <el-date-picker
                    v-model="register.rStartDate"
                    type="datetime"
                    placeholder="选择日期时间">
                    </el-date-picker>
             </div>
            </div>
        </el-col>
      <el-col :span="5">
            <div class="grid-content bg-purple">
                <label>  挂号员</label>
             
                <el-input    v-model="register.rRegisterClerk" placeholder="请输入挂号员姓名"></el-input>
                
            </div>
        </el-col>
      
    </el-row>
    <el-row style="margin-right:auto">
       <h3>患者信息</h3>
       </el-row>
    <el-row :gutter="20" style="margin-top: 30px;">
            
            <el-col :span="6">
              
                <div class="grid-content bg-purple">
                  <label>  患者姓名</label>
                  <el-input v-model="patient.pName" placeholder="请输入患者姓名"></el-input>
    
                   
                </div>
                
            </el-col>
          <el-col :span="6">
                <div class="grid-content bg-purple">
                    <label>患者卡号</label>
                    <el-input v-model="patient.pNo" placeholder="请输入患者卡号"></el-input>
    
                </div>
            </el-col>
          <el-col :span="6">
                <div class="grid-content bg-purple">
                    <label>  患者年龄</label>
                    <el-input v-model="patient.pAge" placeholder="请输入患者年龄"></el-input>
    
                </div>
            </el-col>
          <el-col :span="6">
                <div class="grid-content bg-purple">
                    <label>  出生日期</label>
                    <div class="block">
                        <span class="demonstration"></span>
                        <el-date-picker
                        v-model="patient.pStartDate"
                        type="date"
                        placeholder="选择日期">
                        </el-date-picker>
                    </div>
    
    
                </div>
            </el-col>
          
        </el-row>
        <el-row :gutter="20" style="margin-top: 10px;">
      <el-col :span="7">
                <div class="grid-content bg-purple">
               
                    <label>  性别</label>
                    <el-input v-model="patient.pSex"  placeholder="1表示男0表示女"></el-input>
                   
                </div>
        </el-col>
        <el-col :span="8">
                <div class="grid-content bg-purple">
                    <label>  手机号码</label>
                    <el-input v-model="patient.pPhone" placeholder="请输入手机号码"></el-input>
                </div>
        </el-col>
        <el-col :span="8">
                <div class="grid-content bg-purple">
                    <label>  身份证号</label>
                    <el-input v-model="patient.pCard" placeholder="请输入身份证号"></el-input>
                </div>
        </el-col>
     
    </el-row>
    <el-row :gutter="20" style="margin-top: 10px;">
        <el-col :span="6">
                <div class="grid-content bg-purple">
                    <label>  地址</label>
                    <el-input v-model="patient.pProvince" placeholder="请输入地址(省份)"></el-input>
                </div>
        </el-col>
        <el-col :span="12">
                <div class="grid-content bg-purple">
                    <label>  详细地址</label>
                    <el-input v-model="patient.pPlace" placeholder="请输入详细地址"></el-input>
                </div>
        </el-col>
        </el-row>
        <el-row :gutter="20" style="margin-top: 10px;">
            <el-col :span="18">
                <div class="grid-content bg-purple">
                    <label> 备注</label>
                    <el-input  v-model="patient.pArea" placeholder="请输入备注内容"></el-input>
                </div>
        </el-col>
        </el-row >
    
        <el-dialog title="挂号收费" :visible.sync="diacharge">
      <el-form >
      
        <el-form-item label="应收金额">
            <el-input v-model="charge.creceivable" style="width:200px" placeholder="请输入金额"></el-input>
        </el-form-item>
    
       
        <el-form-item label="实收金额" >
            <el-input  v-model="charge.crealityMoney" style="width:200px" placeholder="请输入金额"></el-input>
        </el-form-item>
        <el-form-item label="支付方式" >
          <el-input v-model="charge.cpayment" placeholder="请输入支付方式(微信/支付宝/银行卡/)"></el-input>
           
        </el-form-item>
    
      </el-form>
      <div slot="footer" >
        <el-button @click="diacharge = false">取 消</el-button>
        <el-button @click="addQuery" type="primary">确 定</el-button>
      </div>
    </el-dialog>
    
    <el-dialog title="挂号收费" :visible.sync="diacharge">
  <el-form >
  
    <el-form-item label="应收金额">
        <el-input v-model="charge.cReceivable" style="width:200px" placeholder="请输入金额"></el-input>
    </el-form-item>

   
    <el-form-item label="实收金额" >
        <el-input  v-model="charge.cRealityMoney" style="width:200px" placeholder="请输入金额"></el-input>
    </el-form-item>
    <el-form-item label="支付方式" >
      <el-input v-model="charge.cPayment" placeholder="请输入支付方式(微信/支付宝/银行卡/)"></el-input>
       
    </el-form-item>

  </el-form>
  <div slot="footer" >
    <el-button @click="diacharge = false">取 消</el-button>
    <el-button @click=addList type="primary">确 定</el-button>
  </div>
</el-dialog>
    
    </div>
    
    
    
    </template>
    
    <script>
    import { addRegsterList,getRegsterList} from "@/api/patientRegster/regsterList";
    import {addPatient } from "@/api/patientsystem/patient";
    import {  addChargeList } from "@/api/patientRegster/chargeList";
    


    
    export default{
        data(){
            return{
                
                diacharge:false,
                register:{rNo:'',tDepar:'', tType:'', rDoctor:'',rRegister:'',rDisease:'',rStartDate:'',rRegisterClerk:''},
                patient:{pName:'',pNo:'',pAge:'',pstartDate:'',pSex:'',pPhone:'',pCard:'',pProvince:'',pPlace:'',pArea:''},
                charge:{cReceivable:'',cRealityMoney:'',cPayment:''},
                dearpsList:[],
               
                doctorList:[],
                checkList:[],
                id:'',
               
            }
        },
        methods:{
            chargeregient(){
                this.diacharge=true
                
            this. id=  this.getDtId();
            console.log(id);

            },
            addList(){
                

                this.patient.id=this.id
                this.register.patientId=this.id
                this.charge.patientId=this.id
                addPatient(this.patient).then(response=>{
                    
                });
                addRegsterList(this.register).then(response=>{

                });
                addChargeList(this.charge).then(response=>{

                })
                this.diacharge=false;
                this.$router.push({
                    path: 'regster1',
       
      })

            },
            getDtId() {
      var d = new Date();
      var year = d.getFullYear();
      var month = d.getMonth() + 1;
      var date = d.getDate();
      var day = d.getDay();
      var hours = d.getHours();
      var minutes = d.getMinutes();
      var seconds = d.getSeconds();
      var ms = d.getMilliseconds();
      year = (year + "").substring(2);
      if (month <= 9)
        month = "0" + month;
      if (date <= 9)
        date = "0" + date;
      if (hours <= 9)
        hours = "0" + hours;
      if (minutes <= 9)
        minutes = "0" + minutes;
      if (seconds <= 9)
        seconds = "0" + seconds;
      let num = Math.ceil(Math.random()*100);
      var id = year + month + date + hours + minutes + seconds + num;
      return id;
    },
            
         
        },
        created(){
            this.queryDepars();
            this.queryDoctor();
            this.queryCheck();
        }
    }
    
    </script>
    
    <style scoped>
    .div{
        margin-top: 20px;margin-bottom: 20px;margin-left: 100px;
    }
     
    
    </style>